﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ImobitechDao;
using ImobitechModel.com.Constantes;
using ImobitechModel.Facade;

namespace ImobitechModel.com.Command
{
    public class InsertPlan : Comando
    {
        public Object executar(IDictionary<string, string> values)
        {
            Plan plan = new Plan();
            plan.Name = values.First(p => p.Key == NomeCampoConstantes.campo_planName).Value;
            double receber = 0;
            double.TryParse(values.First(p => p.Key == NomeCampoConstantes.campo_planValue).Value, out receber);
            plan.Value = receber;

            DateTime data = new DateTime();
            DateTime.TryParse(values.First(p => p.Key == NomeCampoConstantes.campo_planDateStart).Value, out data);
            plan.Date_Start = data;
            DateTime.TryParse(values.First(p => p.Key == NomeCampoConstantes.campo_planDateFinish).Value, out data);
            plan.Date_Finish = data;

            AnuncioFacade planFacade = AnuncioFacade.getInstance();
            return planFacade.insertPlan(plan);
        }
    }
}


//namespace ImobitechModel.com.Command
//{
//    public class InserirImovel : Comando
//    {
//        public Object executar(IDictionary<string, string> valores)
//        {

//            Imovel imovel = new Imovel();
//            imovel.Name = valores.First(p => p.Key == NomeCampoConstantes.campo_imovelNome).Value;

//            ImovelFacade imovelFacade = ImovelFacade.getInstance();
//            return imovelFacade.inserirImovel(imovel);
//        }
//    }
//}